package PRQuadtree;

public class Point implements TwoDComparable<Point> {

	private long xcoord;
	private long ycoord;

	public Point() {
		xcoord = 0;
		ycoord = 0;
	}
	public Point(long x, long y) {
        xcoord = x;
        ycoord = y;
    }

	public long getX() {
		return xcoord;
	}
	public long getY() {
		return ycoord;
	}
	public boolean equals(Object other) {
		if ( other == null ) return false;
		if ( !this.getClass().equals(other.getClass()) )
		   return false;
		Point o = (Point) other;
		return ( this.xcoord == o.xcoord &&
				 this.ycoord == o.ycoord);

	}
	public Direction compare2D(Point other) {
		// point is on the same y axis as this
		if(other.getX() == xcoord){
			//point is at the same location as this
			if(other.getY() == ycoord)
				return Direction.NONE;
			//point other is south of this point
			else if(other.getY() > ycoord)
				return Direction.SE;
			//point is south of this
			else
				return Direction.NE;
		}
		//point is to the right of this
		else if(other.getX() > xcoord){
			//point is directly east of this
			if(other.getY() == ycoord)
				return Direction.SE;
			//point is to the south east of this
			else if(other.getY() > ycoord)
				return Direction.SE;
			//point is to the north east of this
			else
				return Direction.NE;
		}
		//point is to the left of this
		else{
			//point is directly west of this
			if(other.getY() == ycoord)
				return Direction.NW;
			//point is to the south west of this
			else if(other.getY() > ycoord)
				return Direction.SW;
			//point is to the south west of this
			else
				return Direction.NW;
		}
	}
	public String toString() {

		return new String("(" + xcoord + ", " + ycoord + ")");
	}
}
